#!/usr/bin/env python
# -*- coding:utf-8 -*-
# __author__ = "tingfeng"
# Date: 2020/4/30

import time

from appium import webdriver
#from selenium import webdriver
#from selenium import webdriver
from util.write_user_command import WriteUserCommand
from util.server import  Server
class BaseDriver:
    def android_driver(self,i):
            print("this is app_android:",i)
            #devices_name adb devices
            #port
            a = str(i)
            print(a)
            write_file = WriteUserCommand()
            devices = write_file.get_value('user_info_'+a ,'deviceName')
            port = write_file.get_value('user_info_'+a,'port')
            C_caps = {}
            C_caps["platformName"] = "Android"
            #C_caps["platformVersion"] = "9"
            C_caps["deviceName"] = devices
            #C_caps["app"] = "C:/Users/U/Desktop/fsdownload/youbei-test.apk"
            #C_caps["appPackage"] = "com.youbei.chefu"
            C_caps["appPackage"] = "com.chebei.ycb2b"
            #C_caps["appActivity"] = "com.youbei.chefu.MainActivity"
            C_caps["appActivity"] = "com.chebei.ycb2b.activity.splash.SplashActivity"
            C_caps["noReset"] = True
            C_caps["unicodeKeyboard"] = True  # 使用Unicode编码方式发送字符串
            C_caps["resetKeyboard"] = True  # 隐藏键盘
            C_caps["automationName"] = "uiautomator2"
            print(C_caps)

            c_driver = webdriver.Remote("http://127.0.0.1:"+ port +"/wd/hub", C_caps)
            time.sleep(10)

            return c_driver

    def ios_driverC(self,i):
        pass

    def ios_driverB(self,i):
        pass

if __name__ == '__main__':
    server = Server()
    server.main()
    base_driver = BaseDriver()
    base_driver.android_driver(0)



